package no.sachmuld.methodcombination.examples.reflection.roles.observer;

import no.sachmuld.methodcombination.api.CrosscuttingBehaviour;
import no.sachmuld.methodcombination.api.MethodInvocation;
import no.sachmuld.methodcombination.api.reflection.Crosscutting;
import no.sachmuld.methodcombination.examples.reflection.roles.MethodCombinationWithRoleSupport;
import no.sachmuld.methodcombination.examples.reflection.roles.Role;

/**
 *
 */
public class Foo extends MethodCombinationWithRoleSupport<Role, CrosscuttingBehaviour> {

    private int i;

    public Foo() {
        with(new FooBehaviour() {
            @Override
            public void bar(int i, MethodInvocation<Void> methodInvocation) {
                Foo.this.i = i;
            }
        });
    }

    final public void bar(int i) {
        new Crosscutting<String>().build(FooBehaviour.class, Foo.class, "bar", Integer.TYPE).execute(this, chain(), i);
    }

    @Override
    public Foo with(CrosscuttingBehaviour... behaviours) {
        super.with(behaviours);
        return this;
    }
}
